@extends('backend/layouts/default')
@section('title')
Danh sách Danh mục từ điển
@stop
@section('content')
<h3>
    <span class="glyphicon glyphicon-pencil"></span> Danh sách danh mục từ điển
<!--    <a href="" data-toggle="modal" data-target="#modal_newpost" class="btn btn-default btn-xs"><span
            class="glyphicon glyphicon-plus-sign"></span> Hợp âm mới</a>-->
</h3>
<div class="box">
    <div class="box-header">
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <div class="row">
            <div class="col-ld-2 col-md-3 col-sm-3">
                <ul class="nav nav-pills nav-stacked">
                    <li >

                    </li>

                </ul>
            </div>
            <div class="col-ld-10 col-md-9 col-sm-9">
               <form method="get" action="" autocomplete="off" role="form" class="form-inline">
                    <input type="hidden" name="_token" value=""/>

                    <div class="form-group">
                        <input class="form-control" type="text" name="word"  value="<?= $data['appends']['word'] ?>"/>
                    </div>
                    <input type="submit" class="btn btn-default btn-info" name="search" value="Tìm"/>
                </form>
                <hr/>
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th width="60">id</th>
                            <th width="60">parent_id</th>
                            <th class="span6">Tiêu đề</th>
                            <th width="150">Ngày tạo</th>
                            <th width="150">Tác vụ</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($data['categories'] as $category)
                        <tr>
                            <td>{{$category->id}}</td>
                            <td>{{$category->parent_id}}</td>
                            <td>{{$category->title}}</td>
                            <td>{{$category->created_at}}</td>
                            <td>    

                                <a href="{{route('dictionary/category/edit',$category->id)}}" class="btn btn-mini btn-default">@lang('button.edit')</a>                             

                                <a href="{{route('dictionary/category/delete',$category->id)}}" class="btn btn-mini btn-danger">@lang('button.delete')</a>                             

                            </td>
                        </tr>
                        @endforeach()
                        <tr> 
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td>
                                <a href="{{route('dictionaries/categories/create')}}" class="btn " style="background-color: red; color: white">Tạo danh mục</a>      
                            </td>
                        </tr>
                    <script>
                        function show_confirm(obj) {
                            var r = confirm("Bạn có thực sự muốn xóa?");
                            if (r == true)
                                window.location = obj.attr('href');
                        }
                        $('a.btn-danger').click(function (event) {
                            event.preventDefault();
                            show_confirm($(this));
                        });
                    </script>
                    </tbody>
                </table>
                {{ $data['categories']->links() }}
            </div>
        </div>
    </div>
</div>
@stop